!> Test for fffc_math
module test_fffc_math

    use testdrive, only: new_unittest, unittest_type, error_type, check
    use fffc_math, only: percent
    use fffc_kinds, only: wp => fffc_real_kind
    implicit none

    private
    public :: collect_math

contains

    subroutine collect_math(testsuite)
        type(unittest_type), intent(out), allocatable :: testsuite(:)

        allocate (testsuite, source=[ &
                  new_unittest('percent', test_percent) &
                  ])

    end subroutine collect_math

    subroutine test_percent(error)
        type(error_type), intent(out), allocatable :: error

        call check(error, percent(1.0_wp), "100%")
        if (allocated(error)) return

        call check(error, percent(0.0_wp), "  0%")
        if (allocated(error)) return

        call check(error, percent(0.5_wp), " 50%")
        if (allocated(error)) return

        call check(error, percent(10.0_wp), "999%")
        if (allocated(error)) return

    end subroutine test_percent

end module test_fffc_math
